class NewspaperController < ApplicationController
    @@contentList = ["Feature", "News", "Style", "Sports","Opinion"]
    
  def index
		@listArticles = getListArticles
		@mainStory = Article.find_articles_to_be_posted.reverse[0]
		@secondaryStory = Article.find_articles_to_be_posted.reverse[1]
  end
  
  def view
    @listArticles = getListArticles
    @currentArticle = Article.find(params[:id])
  end
  
  def viewSec
    @listArticles = getListArticles
    @tempArticlesList = Article.find_articles_to_be_posted.reverse
    @articles = Array.new(0)
    @temp = Article.find(params[:id])
    for article in @tempArticlesList
      if article.section == @temp.section 
        @articles << article
      end
    end
  end
  
  def viewOpin
    @listArticles = getListArticles
  end
  
  
  def listall
    @listArticles = getListArticles
    @articles = Article.find_articles_to_be_posted.reverse
  end
  
  def getListArticles
    @tempArticleList = Article.find_articles_to_be_posted.reverse
		tempListArticles = Array.new(0)
    for i in 0..3
		  for article in @tempArticleList
		    if article.section == @@contentList[tempListArticles.size] && article != @tempArticleList[0] && article != @tempArticleList[1]
		      tempListArticles << article
		    end
		  end
	  end
	  return tempListArticles
  end
end
